import java.net.*;
//测试IP
public class ConfigIP {
    public static void main(String[] args) {
        try {
            //查询本机地址
                //方法1.
            InetAddress localhost = InetAddress.getByName("127.0.0.1");
            System.out.println(localhost);
                //方法2.
            InetAddress localhost2 = InetAddress.getByName("localhost");
            System.out.println(localhost2);
                //方法3.
            InetAddress localhost3 = InetAddress.getLocalHost();
            System.out.println(localhost3);

            //查询网站IP
            InetAddress zaizai = InetAddress.getByName("zaizai123.cn");
            System.out.println(zaizai);
            InetAddress baidu = InetAddress.getByName("www.baidu.com");
            System.out.println(baidu);
        } catch (UnknownHostException e) {
            throw new RuntimeException(e);
        }
    }
}
